home *** CD-ROM | disk | FTP | other *** search
- Path: cville-srv.wam.umd.edu!jsquires
- From: jsquires@wam.umd.edu (jeffrey d squires)
- Newsgroups: comp.lang.c
- Subject: using MALLOC() w/ 2-d arrays
- Date: 26 Jan 1996 05:09:22 GMT
- Organization: University of Maryland College Park
- Message-ID: <4e9nm2$nna@cville-srv.wam.umd.edu>
- NNTP-Posting-Host: rac3.wam.umd.edu
- X-Newsreader: TIN [version 1.2 PL0]
-
- I have a function that takes as one of its arguments:
-
- unsigned char image[MAX_Y][MAX_X}
-
-
- I have a number of images which is determined at run time,
- therefore I can't declare the size of image_array[][MAX_Y][MAX_X].
-
- In other words, I want to be able to allocate space for as many
- of these images as I need at run time. I've tried everything
- (except the correct way).
-
- I think I need something of the form:
-
- unsigned char * image_array[MAX_Y][MAX_X];
-
- image_array = (unsigned char *) malloc(.....sizeof(unsigned char));
-
-
- I know that if I declare:
- unsigned char image_array[10][MAX_Y][MAX_X];
-
- I can successfully send this to the function, but what
- if I don't know that I'll need ten? Can anyone tell
- me the proper solution? Thank you.
-
-
-